package com.example.springboot;

import org.apache.catalina.tribes.ChannelListener;
import org.apache.catalina.tribes.Member;
import org.apache.catalina.tribes.tipis.AbstractReplicatedMap;

import java.io.Serializable;

public class MapClusterListener implements ChannelListener {
    @Override
    public void messageReceived(Serializable msg, Member sender) {
        if(msg instanceof MyMapValue.MyKeyValueClusterMessage){
            MyMapValue.MyKeyValueClusterMessage mapMessage= (MyMapValue.MyKeyValueClusterMessage) msg;
            Serializable key = mapMessage.getKey();
            System.out.println("收到集群消息");
            System.out.println(key);
            System.out.println(mapMessage.getValue());
        }
    }

    @Override
    public boolean accept(Serializable msg, Member sender) {
        return msg instanceof MyMapValue.MyKeyValueClusterMessage;
    }
}
